"""
    http://projecteuler.net/problem=3
    
    The prime factors of 13195 are 5, 7, 13 and 29.

    What is the largest prime factor of the number 600851475143 ?
"""
NUMBER = 600851475143
        
def get_factors(number):
    for n in xrange(2, number):
        if number % n == 0:
            #print n, number / n
            return get_factors(n) + get_factors(number / n)
    return [number]

def test_case():
    number = 13195
    expected = [5, 7, 13, 29]
    factors = get_factors(number)
    assert factors == expected, "get_factors(%d) (%s) != expected %s" % (
            number, factors, expected)
    print "passed test case!"
    
def solution():
    factors = get_factors(NUMBER)
    return max(factors)
    


if __name__ == '__main__':
    test_case()
    print solution()
    

